<?
$order=get_segment(3);
?>
<h1 class="ttt"><span>الطلبات المضافة</span></h1>

<div id="inner">
    <div class="submit" id="ui-state-persist">
   <a href="<?php echo base_url()?><?php echo get_segment(1)?>/index/up/<?php echo  get_segment(4)?>" data-role="button" data-theme="b"  data-icon="arrow-u" data-mini="true" data-iconpos="right"  <? if ( $order == 'up' || empty($order) ) { ?>class="ui-btn-active ui-state-persist" <? } ?> ><?php echo lang('label_sort_order_desc')?></a>
  <a href="<?php echo base_url()?><?php echo get_segment(1)?>/index/dw/<?php echo  get_segment(4)?>" data-role="button" data-theme="b" data-icon="arrow-d" data-mini="true" data-iconpos="right" <? if ( $order == 'dw') { ?> class="ui-btn-active ui-state-persist" <? } ?> ><?php echo lang('label_sort_order_asc')?></a>
    </div>

    <?
    $r=0;
    foreach ($result as $val) {
        $r++;
        
        $items = get_items_under_order($val->id);
        //Display invoices button
        $display_invoices = $this->inovices->display_inovices_button($val->id, $this->user_id, 1);
        ?>
        <div data-role="collapsible" <? if($r == 1 ){ ?>data-collapsed="false"<? } ?> >
            <h2># <?php echo  $val->id ?></h2>
            <ul data-role="listview" data-filter="true" data-filter-theme="c" data-divider-theme="d">
                <li data-role="list-divider" data-theme="c" style="padding:5px 3px; ">

                    <div data-role="controlgroup" data-type="horizontal" data-mini="true">
                        <? if ($val->order_type === 'item_order' && $display_invoices['display'] != 2 ) { ?><a href="<?php echo  base_url() ?>orders/payment/<?php echo  $val->id ?>" data-role="button" data-icon="puls"   data-iconpos="right" data-theme="b"><?php echo lang('label_bill_payment__details')?></a> <? } ?>

                        <?php echo  display_invoice_button($display_invoices['display'], $display_invoices['id']) ?>

                        <a href="#" data-role="button" data-icon="delete" data-iconpos="right" data-theme="b">Right</a>
                    </div>
                    <span class="order_create_date"><?php echo lang('label_created_date')?> : <?php echo  $val->create_date ?></span>

                </li>
                <!-- statrt_for_each -->
                <?
                foreach ($items as $value) {
                    ?>
                
                    <li class="order_list">
                        <h1 class="item_title"><?php echo  $value->title ?> </h1>
                        <div class="order_details">
                            <div><span> <?php echo lang('label_quantity')?></span><label><?php echo  $value->quantity ?></label></div>
                            <div><span> <?php echo lang('label_weight')?></span><label><?php echo  $value->weight ?></label></div>
                            <div><span> <?php echo lang('label_color')?></span><label><?php echo  $value->color ?></label></div>
                            <div><span> <?php echo lang('label_price')?></span><label><?php echo  $value->price ?></label></div>
                            <div><span> <?php echo lang('label_bill_shiping_rate')?></span><label><?php echo  $value->shiping_cost ?></label></div>
                            <div><span> <?php echo lang('label_total')?></span><label><?php echo  (($value->price * $value->quantity) + $value->shiping_cost) ?></label></div>
                            <?
                            if ($value->perfum == 'YES' || $value->battery == 'YES') {
                                ?>
                                <div><span>&nbsp;</span><label><? if ($value->battery == 'YES') { ?><span class="battery">{battery}</span> <? } ?>
                                        <? if ($value->perfum == 'YES') { ?><span class="perfum">{perfum}</span> <? } ?></label></div>
                                        <?
                                    }
                                    ?>
                        </div>
                        <div class="order_tool">
                            <div class="statues">
                                <?php echo  $value->Statue ?>
                            </div>
                            <div class="order_button">
                                <div data-role="controlgroup" data-type="horizontal" data-mini="true">
                                    
                                   <?php echo mobile_display_button_check('orders/check/' . $value->id.'-'.$value->order_id, $value->statue_id, $extra = 'data-iconpos="" ')?>
                                    <?php echo  mobile_display_button_edit('orders/edit_'.$value->type.'/' . $value->id, $value->statue_id, 'data-iconpos="" data-iconpos="right"') ?>
                                    <?  //mobile_display_button_delete('orders/delete/' . $value->id, $value->statue_id, false, 'data-rel="popup" data-iconpos="right" ') ?>
                                    <?php echo  mobile_display_button_delete('#confirm_' . $value->id,$value->statue_id,false, 'data-rel="popup" data-iconpos="right" data-theme="b" ') ?>
                                    <?php echo  mobile_popup('confirm_delete', array('link' => base_url() . 'orders/delete/' . $value->id, 'div_id' => 'confirm_' . $value->id,'data-iconpos="right"')) ?>  
                                    <a href="<?php echo base_url()?>orders/histroy/<?php echo $value->id?>" data-iconpos="right" data-icon="histroy" data-role="button" data-theme="b"><?php echo lang('label_sort_step')?></a>

                                </div>
                            </div>
                        </div>
                        <?
                        if(!empty($value->note)){
                        ?>
                        <div class="note">
                            <div class="alert alert-block">
                            <?php echo lang('label_note')?>
                            <?php echo $value->note?>
                            </div>
                        </div>
                        <?
                        }
                        ?>
                    </li>

                    <?
                }
                ?>

            </ul>
        </div> 
        <?
    }
    ?>           
</div>
<?php echo $pagination?>